var newContainer = function(el){
	this.el = el;
	var that = this;
	var main_div = document.createElement("div");
	main_div.style.position="relative";

	var top_div = document.createElement("div");
	top_div.style.display="none";
	
	var middle_div = document.createElement("div");
	middle_div.style.clear="both";
	
	var bottom_div = document.createElement("div");
	bottom_div.style.display="none";

	var left_div = document.createElement("div");
	left_div.style.display="none";
	
	var right_div = document.createElement("div");
	right_div.style.display="none";
	
	var center_div = document.createElement("div");
	center_div.style.display="none";

	var elements = el.childNodes;
	var mainHeight = free_height(el);
	var mainWidth = free_width(el);
	for(var i=0;i<elements.length;i++){
//		alert(elements[i].getAttribute("region"));
		if(elements[i].getAttribute){
			var str_region = elements[i].getAttribute("region");
			switch(str_region){
				case "top":
					top_div = elements[i];
					elements[i].parentNode.removeChild(elements[i]);
					i--;
				break;
				case "bottom":
					bottom_div = elements[i];
					elements[i].parentNode.removeChild(elements[i]);
					i--;
				break;
				case "center":
					center_div = elements[i];
					elements[i].parentNode.removeChild(elements[i]);
					center_div.style.styleFloat="left";
					center_div.style.cssFloat="left";
					i--;
				break;
				case "left":
					left_div = elements[i];
					elements[i].parentNode.removeChild(elements[i]);
					left_div.style.styleFloat="left";
					left_div.style.cssFloat="left";
					i--;
				break;
				case "right":
					right_div = elements[i];
					elements[i].parentNode.removeChild(elements[i]);
					right_div.style.position="absolute";
					right_div.style.top="0px";
					right_div.style.right="0px";
//					right_div.style.styleFloat="left";
//					right_div.style.cssFloat="left";
					i--;
				break;
			}
		}
	}
	
	middle_div.appendChild(left_div);
	middle_div.appendChild(center_div);
	middle_div.appendChild(right_div);

	main_div=el.cloneNode(true);
	main_div.appendChild(top_div);
	main_div.appendChild(middle_div);
	main_div.appendChild(bottom_div);

	top_div.style.border="1px solid green";
	middle_div.style.border="1px solid blue";
	middle_div.style.position="relative";
	bottom_div.style.border="1px solid green";
	left_div.style.border="1px solid orange";
	right_div.style.border="1px solid orange";
	center_div.style.border="1px solid red";
	
	el.parentNode.replaceChild(main_div,el);
	main_div.style.position="relative";

	this.resize = function(){
		var bodyOverflow = document.body.style.overflow;
		var mainOverflow = main_div.style.overflow;
		var middleOverflow = middle_div.style.overflow;
		var topOverflow = top_div.style.overflow;
		var bottomOverflow = bottom_div.style.overflow;
		var centerOverflow = center_div.style.overflow;
/*
		main_div.style.overflow="hidden";
		middle_div.style.overflow="hidden";
		top_div.style.overflow="hidden";
		bottom_div.style.overflow="hidden";
		center_div.style.overflow="hidden";
		left_div.style.overflow="hidden";
		right_div.style.overflow="hidden";
*/
		document.body.style.overflow="hidden";
		center_div.style.minWidth  = "50px";
		middle_div.style.minWidth = left_div.offsetWidth + right_div.offsetWidth + 50 +"px";
		main_div.style.minWidth = left_div.offsetWidth + right_div.offsetWidth + 50 + parseFloat(middle_div.style.borderLeftWidth) + parseFloat(middle_div.style.borderRightWidth)+"px";

//		middle_div.style.minHeight = 50 +"px";
		main_div.style.minHeight = 50 + top_div.offsetHeight + bottom_div.clientHeight + "px";

		main_div.style.height = free_height(main_div)+"px";
		middle_div.style.height = free_height(middle_div) - top_div.offsetHeight - bottom_div.offsetHeight+"px";
		center_div.style.height = free_height(center_div)+"px";
		right_div.style.height = free_height(center_div)+"px";
		left_div.style.height = free_height(center_div)+"px";
		center_div.style.width  = free_width(center_div) - left_div.offsetWidth - right_div.offsetWidth+"px";
/*
		main_div.style.overflow=mainOverflow;
		middle_div.style.overflow=middleOverflow;
		top_div.style.overflow=topOverflow;
		bottom_div.style.overflow=bottomOverflow;
		center_div.style.overflow=centerOverflow;
		left_div.style.overflow=leftOverflow;
		right_div.style.overflow=rightOverflow;
*/
		document.body.style.overflow = bodyOverflow;
	}
	this.resize();
	alert(free_width(center_div) - left_div.offsetWidth - right_div.clientWidth);
	alert(free_height(middle_div) - top_div.offsetHeight - bottom_div.offsetHeight);
//	main_div.style.height = free_height(main_div)+"px";
//	middle_div.style.height = free_height(middle_div) - top_div.offsetHeight - bottom_div.offsetHeight+"px";
//	center_div.style.width  = free_width(center_div) - left_div.offsetWidth - right_div.offsetWidth+"px";
	addEvent(window,"resize",this.resize);
}

